package com.cloudsigns.factorymanager2.produce.bean;

import android.text.TextUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class WorkParkAdjustOrderBean implements Serializable {
    private int adjustDays;// 调整天数
    private String applyAccountId;// 申请人账号ID
    private String applyAccountName;// 申请人账号ID
    private long applyDate;// 申请单时间
    private String id;// id
    private List<String> imgUrlList = new ArrayList<>();//上传图片
    private String reason;// 调整原因说明
    private String status;// 申请单的状态
    private String type;//	调整单类型

    public int getAdjustDays() {
        return adjustDays;
    }

    public void setAdjustDays(int adjustDays) {
        this.adjustDays = adjustDays;
    }

    public String getApplyAccountId() {
        return applyAccountId;
    }

    public void setApplyAccountId(String applyAccountId) {
        this.applyAccountId = applyAccountId;
    }

    public String getApplyAccountName() {
        return applyAccountName;
    }

    public void setApplyAccountName(String applyAccountName) {
        this.applyAccountName = applyAccountName;
    }

    public long getApplyDate() {
        return applyDate;
    }

    public void setApplyDate(long applyDate) {
        this.applyDate = applyDate;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<String> getImgUrlList() {
        return imgUrlList;
    }

    public void setImgUrlList(List<String> imgUrlList) {
        this.imgUrlList = imgUrlList;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void parseJson(JSONObject jsonObject) throws JSONException {
        if (jsonObject.has("adjustDays")) {
            String adjustDaysStr = jsonObject.getString("adjustDays");
            if (null != adjustDaysStr && !TextUtils.isEmpty(adjustDaysStr) && !"null".equals(adjustDaysStr)) {
                setAdjustDays(Integer.parseInt(adjustDaysStr));
            }
        }
        if (jsonObject.has("applyAccountId")) {
            setApplyAccountId(jsonObject.getString("applyAccountId"));
        }
        if (jsonObject.has("applyAccountName")) {
            setApplyAccountName(jsonObject.getString("applyAccountName"));
        }
        if (jsonObject.has("applyDate")) {
            setApplyDate(jsonObject.getLong("applyDate"));
        }
        if (jsonObject.has("id")) {
            setId(jsonObject.getString("id"));
        }
        if (jsonObject.has("imgUrlList")) {
            String imgUrlListJsonArrStr = jsonObject.getString("imgUrlList");
            if (null != imgUrlListJsonArrStr && !imgUrlListJsonArrStr.equals("null") && !TextUtils.isEmpty(imgUrlListJsonArrStr)) {
                JSONArray imgUrlListJsonArr = new JSONArray(imgUrlListJsonArrStr);
                ArrayList<String> imgUrlList = new ArrayList<String>();
                for (int k = 0; k < imgUrlListJsonArr.length(); k++) {
                    imgUrlList.add(imgUrlListJsonArr.getString(k));
                }
                setImgUrlList(imgUrlList);
            }
        }
        if (jsonObject.has("reason")) {
            setReason(jsonObject.getString("reason"));
        }
        if (jsonObject.has("status")) {
            setStatus(jsonObject.getString("status"));
        }
        if (jsonObject.has("type")) {
            setType(jsonObject.getString("type"));
        }
    }
}
